home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / GLUT-3.7 / PROGS / ADA / ada_sphere_procs.adb next >
Encoding:
Text File  |  1998-08-12  |  1.2 KB  |  61 lines

  1.  
  2. with GL; use GL;
  3. with GLU; use GLU;
  4. with Glut; use Glut;
  5. with GNAT.OS_Lib;
  6.  
  7. package body ada_sphere_procs is
  8.  
  9.   procedure display is
  10.  
  11.   begin
  12.     glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  13.     glutSolidSphere(1.0, 10, 10);
  14.     glutSwapBuffers;
  15.   end display;
  16.  
  17.   procedure reshape(w : Integer; h : Integer) is
  18.  
  19.   begin
  20.     glViewport(0, 0, GLsizei(w), GLsizei(h));
  21.   end reshape;
  22.  
  23.   procedure menu (value : Integer) is
  24.  
  25.   begin
  26.     if (value = 666) then
  27.       GNAT.OS_Lib.OS_Exit (0);
  28.     end if;
  29.   end menu;
  30.  
  31.   procedure init is
  32.  
  33.     light_diffuse : array(0 .. 3) of aliased GLfloat :=
  34.       (1.0, 0.0, 0.0, 1.0);
  35.     light_position : array(0 .. 3) of aliased GLfloat :=
  36.       (1.0, 1.0, 1.0, 0.0);
  37.  
  38.   begin
  39.     glClearColor(0.1, 0.1, 0.1, 0.0);
  40.  
  41.     glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse(0)'access);
  42.     glLightfv(GL_LIGHT0, GL_POSITION, light_position(0)'access);
  43.  
  44.     glFrontFace(GL_CW);
  45.     glEnable(GL_LIGHTING);
  46.     glEnable(GL_LIGHT0);
  47.     glEnable(GL_DEPTH_TEST);
  48.     glDepthFunc(GL_LESS);
  49.  
  50.     glMatrixMode(GL_PROJECTION);
  51.     gluPerspective(40.0, 1.0, 1.0, 10.0);
  52.  
  53.     glMatrixMode(GL_MODELVIEW);
  54.     gluLookAt(
  55.       0.0, 0.0, -5.0,
  56.       0.0, 0.0, 0.0,
  57.       0.0, 1.0, 0.0);
  58.   end init;
  59.  
  60. end ada_sphere_procs;
  61.